package com.vogue.supplymall.order.controller;

import javax.annotation.Resource;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.vogue.supplymall.common.domain.dto.ControllerResultInfo;
import com.vogue.supplymall.common.domain.dto.SearchRefundInfo;
import com.vogue.supplymall.common.domain.dto.UserInfo;
import com.vogue.supplymall.order.domain.biz.RefundOrderBiz;

@Controller
public class RefundOrderListController extends BaseController {

    /**
     * The constant log.
     */
    public static final Logger log = LoggerFactory.getLogger(RefundOrderListController.class);
    @Resource
    private RefundOrderBiz refundOrderBiz;
    /**
     * Gets cart.
     * 查询退单主列表
     * @param appver the appver
     * @param searchRefundInfo the searchRefundInfo
     * @return the cart
     */
    @RequestMapping(value = "/is/{appver}/order/refundOrderList", method = RequestMethod.POST)
    public ResponseEntity<Object> getRefundOrderList(@PathVariable("appver") String appver,
                                                     @RequestBody(required = false) SearchRefundInfo searchRefundInfo) {
        log.info("get refundOrder list ");
        if (searchRefundInfo == null) {
            searchRefundInfo = new SearchRefundInfo();
        }
        if (SecurityUtils.getSubject().isAuthenticated()) {
            UserInfo info = (UserInfo) SecurityUtils.getSubject().getPrincipal();
            searchRefundInfo.setLoginId(info.getLoginId());
            if (null != info.getOrganInfo()) {
                searchRefundInfo.setOrganid(info.getOrganInfo().getId());
            }
            searchRefundInfo.setSyscodeid(info.getSyscodeid());
        } else {
            log.info("获取登信息失败！");
        }

        ControllerResultInfo resultInfo = new ControllerResultInfo();
        resultInfo.setData(refundOrderBiz.findRefundOrderList(searchRefundInfo));
        log.info("get refundorder list end ");
        return new ResponseEntity<>(resultInfo, HttpStatus.OK);
    }
}
